#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main() {
    int arr[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
    int i = 0, year = 0, month = 0;
    while (~scanf("%d %d", &year, &month))
    {
        for (i = 1; i <= 12; i++)
        {
            if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
            {
                arr[2] = 29;
            }
            else {
                arr[2] = 28;
            }
            if (i == month)
            {
                printf("%d\n", arr[i]);
            }
        }
    }
    return 0;
}